package edu.hcmus.sow.domain;

import java.io.Serializable;
import java.util.Calendar;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 */

@Entity
@NamedQueries({
      @NamedQuery(name = "findAllFileRevisionComments", query = "select myFileRevisionComment from FileRevisionComment myFileRevisionComment"),
      @NamedQuery(name = "findFileRevisionCommentByContent", query = "select myFileRevisionComment from FileRevisionComment myFileRevisionComment where myFileRevisionComment.content = ?1"),
      @NamedQuery(name = "findFileRevisionCommentByCreatedDate", query = "select myFileRevisionComment from FileRevisionComment myFileRevisionComment where myFileRevisionComment.createdDate = ?1"),
      @NamedQuery(name = "findFileRevisionCommentById", query = "select myFileRevisionComment from FileRevisionComment myFileRevisionComment where myFileRevisionComment.id = ?1"),
      @NamedQuery(name = "findFileRevisionCommentByPrimaryKey", query = "select myFileRevisionComment from FileRevisionComment myFileRevisionComment where myFileRevisionComment.id = ?1"),
      @NamedQuery(name = "findFileRevisionCommentByUpdatedDate", query = "select myFileRevisionComment from FileRevisionComment myFileRevisionComment where myFileRevisionComment.updatedDate = ?1") })
@Table(catalog = "sow", name = "file_revision_comment")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "SharedOnlineWorkspace/edu/hcmus/sow/domain", name = "FileRevisionComment")
public class FileRevisionComment implements Serializable {
   private static final long serialVersionUID = 1L;

   /**
    */

   @Column(name = "ID", nullable = false)
   @Basic(fetch = FetchType.EAGER)
   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @XmlElement
   Integer id;
   /**
    */

   @Column(name = "CONTENT", columnDefinition = "TEXT")
   @Basic(fetch = FetchType.EAGER)
   @Lob
   @XmlElement
   String content;
   /**
    */
   @Temporal(TemporalType.TIMESTAMP)
   @Column(name = "CREATED_DATE")
   @Basic(fetch = FetchType.EAGER)
   @XmlElement
   Calendar createdDate;
   /**
    */
   @Temporal(TemporalType.TIMESTAMP)
   @Column(name = "UPDATED_DATE")
   @Basic(fetch = FetchType.EAGER)
   @XmlElement
   Calendar updatedDate;

   /**
    */
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumns({ @JoinColumn(name = "CREATED_BY", referencedColumnName = "ID") })
   @XmlTransient
   User user;
   /**
    */
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumns({ @JoinColumn(name = "FILE_REVISION_ID", referencedColumnName = "ID", nullable = false) })
   @XmlTransient
   FileRevision fileRevision;

   /**
    */
   public void setId(Integer id) {
      this.id = id;
   }

   /**
    */
   public Integer getId() {
      return this.id;
   }

   /**
    */
   public void setContent(String content) {
      this.content = content;
   }

   /**
    */
   public String getContent() {
      return this.content;
   }

   /**
    */
   public void setCreatedDate(Calendar createdDate) {
      this.createdDate = createdDate;
   }

   /**
    */
   public Calendar getCreatedDate() {
      return this.createdDate;
   }

   /**
    */
   public void setUpdatedDate(Calendar updatedDate) {
      this.updatedDate = updatedDate;
   }

   /**
    */
   public Calendar getUpdatedDate() {
      return this.updatedDate;
   }

   /**
    */
   public void setUser(User user) {
      this.user = user;
   }

   /**
    */
   @JsonIgnore
   public User getUser() {
      return user;
   }

   /**
    */
   public void setFileRevision(FileRevision fileRevision) {
      this.fileRevision = fileRevision;
   }

   /**
    */
   @JsonIgnore
   public FileRevision getFileRevision() {
      return fileRevision;
   }

   /**
    */
   public FileRevisionComment() {
   }

   /**
    * Copies the contents of the specified bean into this bean.
    * 
    */
   public void copy(FileRevisionComment that) {
      setId(that.getId());
      setContent(that.getContent());
      setCreatedDate(that.getCreatedDate());
      setUpdatedDate(that.getUpdatedDate());
      setUser(that.getUser());
      setFileRevision(that.getFileRevision());
   }

   /**
    * Returns a textual representation of a bean.
    * 
    */
   public String toString() {

      StringBuilder buffer = new StringBuilder();

      buffer.append("id=[").append(id).append("] ");
      buffer.append("content=[").append(content).append("] ");
      buffer.append("createdDate=[").append(createdDate).append("] ");
      buffer.append("updatedDate=[").append(updatedDate).append("] ");

      return buffer.toString();
   }

   /**
    */
   @Override
   public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
      return result;
   }

   /**
    */
   public boolean equals(Object obj) {
      if (obj == this)
         return true;
      if (!(obj instanceof FileRevisionComment))
         return false;
      FileRevisionComment equalCheck = (FileRevisionComment) obj;
      if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
         return false;
      if (id != null && !id.equals(equalCheck.id))
         return false;
      return true;
   }
}
